home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / drgnsmth.cpt / Dragonsmith 1.1 / Base files / Utilities / MenuUtils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-10  |  1.7 KB  |  62 lines

  1. /*
  2.     MenuUtils.c
  3.     
  4.     Created    24 May 1992    Extracted from DFilePaths.c
  5.     Modified    11 Jul 1992    Added ShowMenuAction
  6.             15 Jul 1992    Got rid of call to Delay in ShowMenuAction ╤ Delay hogs the CPU
  7.             06 Sep 1992    Added check for last == iLastItem (-1) in CheckOne to allow for an arbitrarily large item
  8.                             group at the end of a menu
  9.  
  10.     Copyright ⌐ 1992 by Paul M. Hoffman
  11.     Send comments or suggestions to paul.hoffman@um.cc.umich.edu
  12.     
  13.     This source code may be freely used, altered, and distributed in any way as long as:
  14.         1.    It is GIVEN away rather than sold (except as expressly permitted by the author)
  15.         2.    This statement and the above copyright notice are left intact.
  16.  
  17. */
  18.  
  19. #include    "MenuUtils.h"
  20. #include    "EventUtils.h"
  21.  
  22. void ShowMenuAction (void)
  23. {
  24.     long        ticks;
  25.     
  26.     YieldCPUTime (2);        /* Wait a little to let the user see the hilited menu title */
  27.     HiliteMenu (0);            /* Then clear the hilited menu (whatever it was) */
  28. }
  29.  
  30. void CheckOne (MenuHandle menu, register short first, register short last, register short itemToCheck)
  31. {
  32.     register short        i;
  33.     short            mark;
  34.     
  35.     if (last == iLastItem)
  36.         last = CountMItems (menu);
  37.     if (itemToCheck < first || itemToCheck > last)
  38.         return;
  39.     for (i = first; i < itemToCheck; i++)
  40.         SetItemMark (menu, i, noMark);
  41.     SetItemMark (menu, itemToCheck, checkMark);
  42.     for (i = itemToCheck + 1; i <= last; i++)
  43.         SetItemMark (menu, i, noMark);
  44. }
  45.  
  46. Boolean ItemIsChecked (MenuHandle menu, short item)
  47. {
  48.     short        mark;
  49.     
  50.     GetItemMark (menu, item, &mark);
  51.     return (mark == checkMark);
  52. }
  53.  
  54. Boolean ToggleMenuItem (MenuHandle menu, short item)
  55. {
  56.     Boolean    newSetting;
  57.     
  58.     newSetting = ! ItemIsChecked (menu, item);
  59.     CheckItem (menu, item, newSetting);
  60.     return newSetting;
  61. }
  62.